export  default function URL(href) {
	
  let origin = '', protocol = '', host = '', port = '', pathname = '', search = '', hash = '', params = {};

  if (href && typeof href === 'string') {
    const matchOrigin = href.match(/(^https?:)\/\/((\w+\.)?(\w+\.?){2,})/);
    if (matchOrigin) {
      origin = matchOrigin[0];
      protocol = matchOrigin[1];
      host = matchOrigin[2];
    }

    const matchPath = new RegExp(matchOrigin[0] + "(:(\\d+))?([^?#]*)?[?#]*");
    const pathMatch = href.match(matchPath);
    if (pathMatch) {
      port = pathMatch[2] || '';
      pathname = pathMatch[3] || '';
    }

    const searchMatch = href.match(/\?([^#\?]*)?/g) || [];
    searchMatch.forEach(searchPart => {
      const pairs = searchPart.substring(1).split('&');
      pairs.forEach(pair => {
        const [key, value] = pair.split('=');
        params[key] = value;
      });
    });
    search = searchMatch.join('').replace(/\?/g, '&');

    const hashMatch = href.match(/#([^?\?]*)?/g) || [];
    hashMatch.forEach(hashPart => {
      const pairs = hashPart.substring(1).split('&');
      pairs.forEach(pair => {
        const [key, value] = pair.split('=');
        params[key] = value; // Note: Hash params are also added to `params`, you might want to separate them
      });
      hash = hashMatch.join('').replace(/#/g, '&'); // Note: This might not be the desired format for `hash`
    });

    // If you want to preserve the hash and search params separately in the original format:
    // hash = (hashMatch[0] || '').substring(1);
    // search = (searchMatch[0] || '').substring(1);
  }
  return {
      origin,
      protocol,
      host,
      port,
      pathname,
      search, // Note: This is now a modified version, you might prefer the original format
      hash,   // Same as `search`
      params
    };
  }